package com.zhubayi.springcloud.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import java.util.UUID;

/**
 * @author zhubayi
 */
@EnableBinding(Source.class) //消息的推送管道
public class MessageProviderImpl implements IMessageProvider{
    @Autowired
    private MessageChannel output; //发送消息通道
    @Override
    public String send() {
        String id= UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(id).build());
        System.out.println("*****发送成功=====>*****"+id);
        return id;
    }
}
